﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ModelLibrary;

namespace WebC
{
    public partial class system_roleuser : clsBaseForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(system_roleuser));
            if (!IsPostBack)
            {
                loadInfo();
            }
        }

        public void loadInfo()
        {
            clsSys clss = null;
            string sFullName = "";
            try
            {
                clss = new clsSys();
                if (!checkModelRightById(17, ref sFullName, (clsBaseLib)clss))
                {
                    errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                    return;
                }
                sModelFullName = sFullName;
                lbUserName.Text = clss.getUserName(m_Id);
                rpttblInfo.DataSource = clss.getUserRoleInfo(m_Id);
                rpttblInfo.DataBind();
            }
            catch (Exception e)
            {
                errorUrl(Convert.ToString(e));
            }
            finally
            {
                if (clss != null)
                {
                    clss.Dispose();
                }
            }
        }

        int m_Id
        {
            get
            {
               return Convert.ToInt32(Request["id"]);
            }
        }

        [Ajax.AjaxMethod]
        public bool setUserRole(int iUId, string sRoleIds)
        {
            bool bResult = false;
            clsSys clss = null;
            try
            {
                clss = new clsSys();
                clss.setUserRole(iUId, sRoleIds);
                bResult = true;
            }
            catch
            {
                bResult = false;
            }
            finally
            {
                if (clss != null)
                {
                    clss.Dispose();
                }
            }
            return bResult;
        }
    }
}